import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect:"/home"
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import( '../views/Login.vue')
  },
  {
    path: '/home',
    name: 'Home',
	meta:{
		isShow:true
	},
    component: () => import( '../views/Home.vue')
  },
  {
    path: '/list',
    name: 'List',
	meta:{
		isShow:true
	},
    component: () => import( '../views/List.vue')
  },
  {
    path: '/cart',
    name: 'Cart',
	meta:{
		isShow:true,
		title:"购物车"
	},
    component: () => import( '../views/Cart.vue')
  },
  {
    path: '/my',
    name: 'My',
	meta:{
		isShow:true
	},
    component: () => import( '../views/My.vue')
  },
  {
    path: '/info/:gId',
    name: 'Info',
    component: () => import( '../views/Info.vue')
  },
  {
    path: '/addresslist',
    name: 'AddressList',
    component: () => import( '../views/AddressList.vue')
  },
  {
    path: '/addressedit',
    name: 'AddressEdit',
    component: () => import( '../views/AddressEdit.vue')
  },
  {
    path: '/order',
    name: 'Order',
    component: () => import( '../views/Order.vue'),
	meta:{
		title:"订单"
	}
  },
  {
    path: '/createOrder',
    name: 'CreateOrder',
    component: () => import( '../views/CreateOrder.vue')
  }
  
]

const router = new VueRouter({
  routes
})

//页面标题 document.title
router.beforeEach((to,from,next)=>{
	document.title=to.meta.title||"新峰商城";
	next();
})

export default router
